<template>
  <div class="card-play-main-container">
    <CardPlayHeader></CardPlayHeader>

    <v-divider class="my-4"></v-divider>

    <CardPlayInitialize v-if="showAllCards"></CardPlayInitialize>
    <CardDeal v-if="showPlayerCards"></CardDeal>
    <CardWinner v-if="showWinner"></CardWinner>

    <div class="d-flex align-center justify-center mt-10">
      <v-btn class="text-none mb-4" color="indigo-darken-3" size="x-large" :variant="isDarkMode ? 'flat' : 'outlined'"
        block @click="onNext">{{
          buttonText }}</v-btn>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue';
import CardDeal from '../components/CardPlay/CardDeal.vue';
import CardPlayHeader from '../components/CardPlay/CardPlayHeader.vue';
import CardPlayInitialize from '../components/CardPlay/CardPlayInitialize.vue';
import { useCardGameStore } from '../stores/card-game.store';
import CardWinner from '../components/CardPlay/CardWinner.vue';
import { useGlobalConfigStore } from '../stores/global-config.store';
const cardGameStore = useCardGameStore()
const globalConfigStore = useGlobalConfigStore()
const isDarkMode = computed(() => {
  return globalConfigStore.isDarkMode
})

const onNext = () => {
  cardGameStore.increaseStep()
}

const showAllCards = computed(() => {
  return cardGameStore.currentStep == 1 || cardGameStore.currentStep == 2
})

const showPlayerCards = computed(() => {
  return cardGameStore.currentStep == 3
})

const showWinner = computed(() => {
  return cardGameStore.currentStep == 4
})

const buttonText = computed(() => {
  return cardGameStore.currentStep != 4 ? 'Next' : 'Play Again'
})
</script>

<style lang="scss" scoped>
.card-play-main-container {
  margin: 1rem 2rem;

  .highlight {
    color: #1867c0;
  }
}
</style>
